//
//  Mediator+BKMy.m
//  bestkeep
//
//  Created by 武探 on 2016/11/3.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "Mediator+BKMy.h"

NSString *const BKMyTarget = @"BKMyAction";
NSString *const BKMyActionMyViewController = @"myViewController";
NSString *const BKMyActionGetUserInfo = @"myUserInfo";
NSString *const BKMyActionGetST = @"getSTWithDataDict:";
NSString *const BKActionGoLogin = @"userGoToLoginWithDict:";
NSString *const BKActionSetDevelopEnviroment = @"setDevelopEnvironmentWithDict:";
NSString *const BK_my_EditAddressVC = @"editShippingAddress:";
NSString *const BK_CouponVC = @"toBK_CouponVC";
NSString *const BK_StorePayVC = @"toBK_StorePayVC";
NSString *const BKSystemMessage = @"toSystemMessageVC";
NSString *const BKUserRegisterEaseMob = @"userRegisterEMMobWithDict:";
NSString *const BKUserGetUnreadMessageNum = @"getUnreadMessageNumber";
NSString *const BKUserReturnUreadMessageNum = @"uNreadMessageNumber";
NSString *const BKUserGetDeviceToken = @"getDeviceTokenWithDict:";
NSString *const BKUserGetUserSecretKey = @"getUserSecretKey:";
NSString *const BKUserLoginOut = @"userLoginOut";
NSString *const BKUserGetMyFavorVC = @"getMyFavorController";
NSString *const BKGetRealNameResult = @"realNameAuthVCWithDict:";
NSString *const BKGoToVIPWithDataDict = @"goToVIPWithDataDict:";

//获取消息
NSString *const BKSystemMessageDidFinishLannuchFuction = @"getMessageStatusWithApplicationFinishLaunchingWithOptionsDataDict:";
NSString *const BKSystemMessageDidBecomeActiveFunction = @"getMessgaeWhthApplicationDidBecomeActiveWithDataDict:";
NSString *const BKSystemMessageWillEnterForegroundFunction = @"getMessageWhenApplicationWillEnterForegroundWithDataDict:";
NSString *const BKSystemMessageApplicationReceiveRemoteNotificationFunction = @"getMessageNumWhenApplicationReceiveRemoteNotificationWithDataDict:";
@implementation Mediator (BKMy)

-(nonnull UIViewController *)BKMy_myViewController {
    
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKMyActionMyViewController];
    
    return [self performWithOptions:options];
}

-(nullable NSDictionary<NSString *,id> *)BKMyUserInfo
{
    MediatorOptions * options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKMyActionGetUserInfo];
    return [self performWithOptions:options];
}

//获取st
-(void)getSTWithServerce:(nonnull NSString *)serverceUrl compeleteBlock:(nonnull BkMyCompleteBlock1)finishBlock
{
    MediatorOptions * options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKMyActionGetST];
    options.parameters = @{@"severceUrl":serverceUrl, @"resultBlock":finishBlock};
    [self performWithOptions:options];
}

//获取用户支付密钥
- (void)BKMy_getUserSecret:(void (^)(id _Nullable))block {
    
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKUserGetUserSecretKey];
    options.parameters = @{@"UserSecretKey" : block};
    [self performWithOptions:options];
}

//设置开发环境
/*
 value 的取值  1开发 2生产 3测试
 */

-(void)setDevelopEnviromentWithValue:(NSInteger)value
{
    MediatorOptions * options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKActionSetDevelopEnviroment];
    NSString * strNum = [NSString stringWithFormat:@"%ld",(long)value];
    options.parameters = @{@"envirValue":strNum};
    [self performWithOptions:options];
}

//登录
-(void)userGoToLoginFromOrignalController:(nonnull UIViewController *)originalVC finishBlock:(nullable BKLoginSuccessBlock)finishBlock
{
    MediatorOptions * options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKActionGoLogin];
    options.parameters = @{@"controller":originalVC, @"resultBlock":finishBlock};
    [self performWithOptions:options];
}

//退出登录
-(void)userLoginOut
{
    MediatorOptions * options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKUserLoginOut];
    [self performWithOptions:options];
}

//注册环信
-(void)registerEaseMobileWithApplication:(nonnull UIApplication *)application easeMobKey:( nonnull NSString *)easeMobKey launchOptions:(nullable NSDictionary *)launchOptions
{
    MediatorOptions * options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKUserRegisterEaseMob];
    if (!launchOptions) {
        
        launchOptions = @{};
    }
    options.parameters = @{@"application":application,
                           @"EaseMobKey":easeMobKey,
                           @"launchOptions":launchOptions};
    [self performWithOptions:options];

}

//实名认证
-(void)realNameAuthVCWithNav:(nonnull UINavigationController *)nav dataParaDict:(nonnull NSDictionary *)dataDict
{
    NSDictionary * dict = @{@"nav":nav,@"dataDict":dataDict};
    MediatorOptions * options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKGetRealNameResult];
    options.parameters = dict;
    
    [self performWithOptions:options];
}

//去我的vip界面
-(void)goToMyVipFromOrignalVC:(nonnull UIViewController *)orignalVC
{
    NSDictionary * paraDict = @{@"targetVC":orignalVC};
    MediatorOptions * options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKGoToVIPWithDataDict];
    options.parameters = paraDict;
    [self performWithOptions:options];
}

//获取未读信息数
-(void)getUnreadMessageNum
{
    MediatorOptions * options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKUserGetUnreadMessageNum];
    [self performWithOptions:options];
}

//获得未读消息数量
-(nonnull NSDictionary *)unreadMessageNumber
{
    MediatorOptions * options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKUserReturnUreadMessageNum];
    return  [self performWithOptions:options];
}

//获取设备的deviceToken
-(void)getDeviceTokenWithDeviceToken:(nullable NSString *)deviceTokenStr
{
    NSString * paraDictStr = deviceTokenStr;
    if (deviceTokenStr == nil) {
        
        paraDictStr = @"";
    }

    MediatorOptions * options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKUserGetDeviceToken];
    options.parameters = @{@"deviceToken":paraDictStr};
    [self performWithOptions:options];
}
//获取我的收藏
-(nonnull UIViewController *)getMyFavorController
{
    MediatorOptions * options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKUserGetMyFavorVC];
    return  [self performWithOptions:options];
}

//收货地址
- (nonnull UIViewController *)BK_my_ShippingAddressVC:(nonnull NSDictionary *)dict {
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BK_my_EditAddressVC];
    options.parameters = dict;
    return [self performWithOptions:options];
}

- (nonnull UIViewController *)BK_couponViewController {
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BK_CouponVC];
    return [self performWithOptions:options];
}

- (nonnull UIViewController *)BKSystemMessageVC {
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKSystemMessage];
    return [self performWithOptions:options];
}
//支付码VC
- (UIViewController *)BKStorePay_VC {
    
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BK_StorePayVC];
    return [self performWithOptions:options];
}




//获取系统消息
-(void)getMessageStatusWithApplication:(nonnull UIApplication *)application didFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions
{
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKSystemMessageDidFinishLannuchFuction];
    if (launchOptions == nil) {
        
        launchOptions = @{};
    }
    
    options.parameters = @{@"Application":application,@"options":launchOptions};
    [self performWithOptions:options];
}

-(void)getMessgaeWhthApplicationDidBecomeActive:(nonnull UIApplication *)application
{
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKSystemMessageDidBecomeActiveFunction];
    options.parameters = @{@"Application":application};
    [self performWithOptions:options];
}

-(void)getMessageWhenApplicationWillEnterForeground:(nonnull UIApplication *)application
{
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKSystemMessageWillEnterForegroundFunction];
    options.parameters = @{@"Application":application};
    [self performWithOptions:options];
}

-(void)getMessageNumWhenApplication:(nonnull UIApplication *)application didReceiveRemoteNotification:(nullable NSDictionary *)userInfo window:(nonnull UIWindow *)window
{
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:BKMyTarget actionName:BKSystemMessageApplicationReceiveRemoteNotificationFunction];
    if (userInfo == nil) {
        
        userInfo = @{};
    }
    options.parameters = @{@"Application":application,@"options":userInfo,@"window":window};
    [self performWithOptions:options];
}

@end
